package com.example.dao;
import com.example.domain.Record;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author luo
 */
@Mapper
public interface RecordDao{
    /**
     * 查询所有打卡信息
     * @return
     */
    @Select("select id, name, satime, entime, status from record")
    public List<Record> selectAllRecord();

    /**
     * id查找
     * @param id
     * @return
     */
    @Select("select * from record where id = #{id}")
    public Record selectRecordById(Integer id);

    /**
     * 模糊查询
     * @param record
     * @return
     */
//    @Select("select * from employment where position like #{position};")
    public List<Record> selectRecordByName(Record record);

    /**
     * 添加信息
     *
     * @param record
     * @return
     */
    @Insert("insert into record (name, satime, entime, status) values (#{name}, #{satime}, #{entime}, #{status})")
    public int addRecord(Record record);

    /**
     * 更新信息
     *
     * @param record
     * @return
     */
    @Update("update record set name=#{name},satime=#{satime},entime=#{entime},status=#{status} where id=#{id};")
    public int updateRecord(Record record);

    /**
     * 更新信息
     *
     * @param name
     * @return
     */

    public int updateRecordByName(String name);

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @Delete("delete from record where id=#{id};")
    public int deleteRecord(Integer id);

    /**
     * springboot整合task
     * 每格一个月定时删除打卡数据
     * @return
     */
    @Delete("delete from record")
    int deleteAll();
}
